
using [java] com.orientechnologies.orient.core.db.document::ODatabaseDocumentTx
using [java] com.orientechnologies.orient.core.record.impl::ODocument
using [java] java.util::Iterator

class Main
{

  static Void main()
  {
    // OPEN THE DATABASE
    ODatabaseDocumentTx db := ODatabaseDocumentTx("local:C:/Data/FantomIDE/fanopticum/OrientDb/db")
    db.delete
    db.create
    db.close
    
    try {
      db.open("admin", "admin")
    } catch (Err e) {
      echo("****Fehler beim oeffnen der Datenbank ****")
      echo(e.cause)
      throw(e)
    }
      
    // CREATE A NEW DOCUMENT AND FILL IT
    ODocument doc := ODocument(db, "Person")
    doc.field( "name", "Luke" )
    doc.field( "surname", "Skywalker" )
    doc.field( "city", ODocument(db, "City").field("name","Rome").field("country", "Italy") );

    // SAVE THE DOCUMENT
    doc.save

    Iterator iter := db.browseClass("Person").iterator
    while(iter.hasNext) {
      echo(iter.next)
    }        
    db.close

    echo("Fini!")
  }

}